package model

import (
	"crypto/sha1"
	"fmt"

	"github.com/jmoiron/sqlx"
	_ "github.com/mattn/go-sqlite3"
)

type Account struct {
	Id       int
	Username string
	Name     string
	Password string
}

var Db *sqlx.DB

func init() {
	var err error
	Db, err = sqlx.Connect("sqlite3", "./myzhanghu.db")
	if err != nil {
		panic(err)
	}
}

func Encrypt(plaintext string) (cryptext string) {
	cryptext = fmt.Sprintf("%x", sha1.Sum([]byte(plaintext)))
	return
}
